<%--
 *  File:    ContactSelect.jsp
 *  @Author: jianni
 *  Date:    2001/12/10
 *
 *  Copyright (C) 2000 - 2001 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/oval-tag.tld" prefix="oval" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>


<% //--------------------------------------  setting logger --%>
<%
  	Category cat = Category.getInstance("jsp.ContactSelect");
%>

<% //--------------------------------------  variant and initialization --%>
<%
  	String strModuleName = "OGM";
	String strTableName = "ovcontact";
%>



<%
  	HashMap CurUserInfo = (HashMap)session.getAttribute("userinfo");
  	String orgname = CurUserInfo.get("orgname").toString();
%>

<% //--------------------------------------  include files list --%>
<%--<%@ include file="/inc/Security.inc" %>--%>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>
<%
String strInfo=request.getParameter("info");
strInfo=(strInfo==null)?"  ":strInfo;
%>

<html>
<head>
<title>ContactSelect</title>
<PageFlow:CheckPageFlow pageName="contactsummary"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="../../css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="../../js/FuncLib.js"></script>
<%@ include file="/inc/SummaryDivision.inc" %>

<% //--------------------------------------  output variant from pageflow --%>
<%
  	Vector contactSummary = (Vector)pageContext.getAttribute("contactsummary");
  	if(contactSummary == null)
  	{
    	contactSummary = new Vector();
  	}
  	cat.debug("The contactsummary is :" + contactSummary);
%>

<script>
function clickContact(id,name)
{
  document.frm.contactid.value = id;
  document.frm.contactname.value = name;
}
function page_summary(actionvalue,orderbyname)
{
  var editform = summaryPrepare(frm,actionvalue,orderbyname);
  editform.action = "ContactSelect.jsp?<%= OvalTools.randomURL() %>&deptid=<%=JspHelper.filterNull(request.getParameter("deptid"))%>&orgid=<%=JspHelper.filterNull((request.getParameter("orgid")!=null)?request.getParameter("orgid"):"")%>&selectopt=<%=JspHelper.filterNull((request.getParameter("selectopt")!=null)?request.getParameter("selectopt"):"")%>";
  editform.target = "_self";
  isRunning = true;
  editform.submit();
}
function setParentValue()
{
  if (document.frm.contactid.value != "")
      opener.page_setContact(document.frm.contactid.value,document.frm.contactname.value);
  window.close();
}
function radiotrue0(rid, vid,contactname)
{
	clickContact(vid,contactname);
	radiotrue(rid);
}

function page_back()
{
    parent.location.href="Blank.jsp?<%= OvalTools.randomURL() %>"
}
function page_relatedarea()
{
  var cid = document.frm.contactid.value;
  //alert(cid);
  window.open("./RelatedArea.jsp?<%= OvalTools.randomURL() %>&contactid=" + cid, "newwindow", "height=450, width=270, top=50, left=50, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no");

}
</script>
</head>

<body>

	<% //--------------------------------------  hidden form variant --%>
	<form name="frm" method="post" action="../../Dispatcher"  target="_parent">
	<input type="hidden" name="pagename" value="contactsummary">
    <input type="hidden" name="actionname">
    <input type=hidden name=info value="<%=JspHelper.filterNull(strInfo)%>">
		<oval:hidden name="orginfo" property="orgid"/>

	<% //--------------------------------------  page location --%>
	<%--@ include file="/inc/PageLocation.inc" --%>

	<table width="100%" cellspacing="0" border="0" cellpadding="0">
  	<tr>
      <table width="100%" border="0" cellspacing="0">
        <tr>
<%--          <%if(privilegeSet != null && privilegeSet.contains("1000000")){%>--%>
          <%--td nowrap--%><%--= label.getLabelName("L_OwnerOrg") + label.getLabelName("L_Colon") --%>
            	<% if (pageContext.getAttribute("orginfo") == null) {%>
            	<input type="hidden" name="orgname" value="<%=JspHelper.filterNull( orgname )%>" size="30" readonly>
            	<%}else{%>
            	<input type="hidden" name="orgname" value="<oval:write name="orginfo" property="orgname"/>" size="30" readonly>
<%--              <%}%>--%>
              <%--a href="javascript:poporg()"><a onclick=""><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/></a></a></td>
          <td>&nbsp;&nbsp;</td--%>
          <%}%>
          <td>
           <table>
         <%@ include file="/inc/SummarySearch.inc" %>
           </table>
          </td>
         </tr>
       </table>
    	</td>
  	</tr>
  	<tr>
    	<td>
      		<table width="100%" border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0">

        	<% //--------------------------------------  summary header --%>
        	<tr  class="deepblue-left">
            	<td width="5%"  class="title_center">&nbsp;</td>
            	<td  class="title_center"><a href="javascript:page_summary('orderby','contactname')"><%= label.getLabelName("L_ContactName") %></a></td>
<%--            	<td width="30%" class="title_center"><a href="javascript:page_summary('orderby','gendername')"><%= label.getLabelName("L_GenderName") %></a></td>--%>
            	<td width="30%" class="title_center"><a href="javascript:page_summary('orderby','roletypename')"><%= label.getLabelName("L_Type1") %></a></td>
<%--            	<td width="16%" class="title_center"><a href="javascript:page_summary('orderby','parentcontactid')"><%= label.getLabelName("L_ParentContact") %></a></td>--%>
            	<td  class="title_center"><a href="javascript:page_summary('orderby','email')"><%= label.getLabelName("L_Email") %></a></td>
            	<td width="15%" class="title_center"><a href="javascript:page_summary('orderby','officephone')"><%= label.getLabelName("L_OfficePhone") %></a></td>
        	</tr>

        	<% //--------------------------------------  default value definition --%>
        	<%
            	int i = 0;
             	String strClassType = new String();
             	Integer nDefaultContactId = new Integer(-1);
                boolean bHasChecked = false;
                String strRoletypename = "";
                String strEmail="";
                String strOfficephone="";
                String strContactname="";
          	%>

          	<% //--------------------------------------  loop results --%>
          	<logic:iterate id="contactsum" collection="<%= contactSummary %>">
        	<%
            	HashMap contactMap = (HashMap)pageContext.getAttribute("contactsum");
            	String strIsDisabled = new String("");
            	String strIsChecked = new String("");
                strRoletypename = (String)(contactMap.get("roletypename"));
                strEmail= (String)(contactMap.get("email"));
                strOfficephone= (String)(contactMap.get("officephone"));
            	if(i%2 == 1)
            	{
              		strClassType = "td-listrom";
            	}else{
              		strClassType = "";
            	}

            	if(!bHasChecked)
            	{
              		strIsChecked = "Checked";
              		bHasChecked = true;
              		nDefaultContactId = (Integer)(contactMap.get("contactid"));
                    strContactname= (String)(contactMap.get("contactname"));
            	}
            	i++;
          	%>

        	<tr  onMouseOver="this.className='tr-over'" onMouseOut="this.className='<%=JspHelper.filterNull( strClassType )%>'"  onClick="javascript:radiotrue0('cbox<%=JspHelper.filterNull( String.valueOf(i))%>', '<%=JspHelper.filterNull( contactMap.get("contactid") )%>','<%=JspHelper.filterNull(contactMap.get("contactname"))%>')"  class="<%=JspHelper.filterNull( strClassType )%>">
          		<td >
              		<input id="cbox<%=JspHelper.filterNull( String.valueOf(i))%>" type="radio" name="radiobutton" <%=JspHelper.filterNull( strIsDisabled )%> value=<%=JspHelper.filterNull( contactMap.get("contactid") )%> class="checkbox" <%=JspHelper.filterNull( strIsChecked)%> >
            	</td>
            	<td >&nbsp;<a href="ContactInfo.jsp?<%= OvalTools.randomURL() %>&orgid=<oval:write name="orginfo" property="orgid"/>&contactid=<%=JspHelper.filterNull( contactMap.get("contactid") )%>" target="down"><%=JspHelper.filterNull( contactMap.get("contactname") )%></a></td>
<%--            	<td >&nbsp;<%=JspHelper.filterNull( contactMap.get("gendername") )%></td>--%>
            	<td >&nbsp;<%=JspHelper.filterNull( contactMap.get("roletypename") )%></td>
<%--            	<td >&nbsp;<%=JspHelper.filterNull( contactMap.get("parent") )%></td>--%>
            	<td >&nbsp;<%=JspHelper.filterNull( contactMap.get("email") )%></td>
            	<td >&nbsp;<%=JspHelper.filterNull( contactMap.get("officephone") )%></td>
          	</tr>
          	</logic:iterate>

          	<% //--------------------------------------  default value --%>
              <input type="hidden" name="contactid" value="<%=JspHelper.filterNull( nDefaultContactId )%>">
              <input type="hidden" name="contactname" value="<%=JspHelper.filterNull(  strContactname)%>">
              <input type="hidden" name="roletypename" value="<%=JspHelper.filterNull( strRoletypename )%>">
              <input type="hidden" name="email" value="<%=JspHelper.filterNull( strEmail )%>">
              <input type="hidden" name="officephone" value="<%=JspHelper.filterNull( strOfficephone )%>">

          	<% //--------------------------------------  flipping page --%>
    		<%@ include file="/inc/SummaryAction.inc" %>
      		</table>

      		<% //--------------------------------------  page operation button --%>
      		<table width="100%" cellspacing="0" cellpadding="0">
        	<tr>
          		<td class="summary_top"></td>
        	</tr>
        	<tr>
          		<td class="td_center">
          		<%if(request.getParameter("info")!=null && request.getParameter("info").equalsIgnoreCase("Y")){%>
          		    <a onclick="page_back()"><custom:button type="1" label="L_Back" imgsrc="back.gif" border="0" style="width:60"/></a>
          		<%}else{%>
            		 <td class="td_center"><a onclick="setParentValue()"><custom:button type="1" label="L_Finish" imgsrc="finish.gif" border="0" style="width:60"/></a></td>
          		<%}%>
          		</td>
        	</tr>
      		</table>
    	</td>
  	</tr>
	</table>
</form>
</body>
</html>


